﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using NGourd.Core.Runners;

namespace NGourd.CLI
{
    class AddAssemblyConfigurationTweak : IConfigurationTweak
    {
        private readonly Assembly assembly;

        public AddAssemblyConfigurationTweak(Assembly assembly)
        {
            this.assembly = assembly;
        }

        public AddAssemblyConfigurationTweak(string fileName)
        {
            var assemblyFile = new FileInfo(fileName);
            if (assemblyFile.Exists == false)
            {
                Console.WriteLine("Couldn't find: {0}", assemblyFile.FullName);
                Environment.Exit(-2);
            }
            assembly = Assembly.LoadFrom(assemblyFile.FullName);
        }

        public void ApplyTo(Configuration config)
        {
            config.Assemblies.Add(assembly);
        }
    }
}
